package com.example.online_exam_system.commons;

import java.io.Serializable;

/**
 * @Classname:Result
 * @program:online-exam_-springboot
 * @author:ZiXuan
 * @crate:2021-11-03-20-20
 **/
public class Result{

    private boolean success;
    private String msg;
    private int code;
    private Object data;

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Result data(Object data){
        this.data=data;
        return this;
    }


    public Result msg(String msg){
        this.msg=msg;
        return this;
    }

    public Result code(int code){
        this.code=code;
        return this;
    }
    public Result success(boolean success){
        this.success=success;
        return this;
    }

    public static Result ok(){
        Result result = new Result();
        result.setCode(200);
        result.setSuccess(true);
        return result;
    }

    public static Result err(){
        Result result = new Result();
        result.setCode(0);
        result.setSuccess(false);
        return result;
    }
}
